#ifndef PGCONN_H
#define PGCONN_H

#include "connect.h"

#define GAMEID	3				// Paigow Poker

class PGPokerOpts;
class PGPokerGame;
class PGHand;

class PGPokerConnection : public Connection
{
	public:
		PGPokerConnection(Server*server, SOCKET client);
		~PGPokerConnection();

		void msgStart();
		void msgAdd(uint8 Byte);
		void msgAdd(int32 SignedLong);
		uint8* msgGetBuf();
		void msgReleaseBuf(int32 Amt);
		void msgEnd();

		bool8	trackGetBalance(int32 *);
		int32	trackAdjustBalance(int32);	// + increases  - decreases
		bool8	trackGetOptions(PGPokerOpts*);
		bool8	trackGetPlayerLimits(int32* minBet, int32* maxBet,
					int32* compFactor);
		bool8	trackNewGame(int32 Bet, int32* Balance, int32 numCards);
		bool8	trackDeal(PGHand* Player);             // kharmon.  10-16-06.  #8226.
		bool8	trackGameDone(int32 Payout, int32 Commission,
					int32* DealerTwoCard, int32* PlayerTwoCard,
					int32 DealerFiveCardJokerAsRank,
					int32 PlayerFiveCardJokerAsRank,
					int32 HiOutcome, int32 LoOutcome, int32 GameOutcome,
					int32 BalAdjust, int32 *Balance,
                    PGHand* Dealer, PGHand* Player);    // kharmon.  10-16-06.  #8226.

		void	trackaddBadPacket(int32 error_reason, char MessageType, char *msgbuf, int32 msglen);
		bool8	trackHasSavedGame(int32* err);
		bool8	trackSaveGame();
		bool8	trackRemoveSavedGame();
		int32	trackValidateLogin();
		int32	trackValidateSession();

		// CSN-7075: New Authentication
		void	trackLogoutSession();

		uint8	getMachineID();
        #ifdef FORCEDSHOE 
        String  GetPID() {return m_pid;}
        #endif


	protected:
		bool8	getResponse();

		void	handleLogin(int32 len);
		void	sendStopMsg();

		bool8	parseCasinoLogin(int32, int32*);
		bool8	parseUnicodeCasinoLogin(int32, int32*);
		
		void	removeCasinoSpecific();

		int32	encode(uint8*, uint8*, int32);
		int32	decode(uint8*, uint8*, int32);

		int32	msgRemove(uint8*, int32*);
		int32	msgRemove(uint8*, uint8*);

		void	allocateXMLTranslator( XMLTranslator** target );

	public:
		void	gameDone();

	protected:
		int32 loggedOn;
		PGPokerGame* game;
		void* casinoSpecific;
		int32 minBet, maxBet, useCommission;
		int32 compFactor;
		int32 msglen;
		uint8 msgbuf[256];

        #ifdef FORCEDSHOE       //RPF 20100317 When forcing the shue now filter by pid
        String  m_pid;
        #endif


	// [AO 2008-01-16] Refactoring for HA
	private:
		bool ValidateSession();
};

#endif
